﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ZerAx.ObjectNotation
{
    public class ZonTagged : Zon
    {
        public override ZonType Type => ZonType.Tagged;
        public string tag = null;
        public Zon data = null;

        public ZonTagged() { }

        public ZonTagged(string tag, Zon data)
        {
            this.tag = tag;
            this.data = data;
        }

        public override void Initialize(BinaryReader reader)
        {
            tag = reader.ReadString();
            data = Deserialze(reader);
        }

        public override void SerializeData(BinaryWriter writer)
        {
            writer.Write(tag);
            data.Serialize(writer);
        }

        public override string ToString()
        {
            return $"\"{tag}\":{data}";
        }
    }
}
